home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3638 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  48 lines

  1. Path: news.erg.cuhk.hk!usenet
  2. From: Lawrence Xiao <hkshiou3@se.cuhk.hk>
  3. Newsgroups: comp.lang.c
  4. Subject: floating point dynamic array
  5. Date: Tue, 30 Jan 1996 21:25:20 -0800
  6. Organization: Engineering Faculty CUHK
  7. Message-ID: <310EFD40.2D03@se.cuhk.hk>
  8. NNTP-Posting-Host: slip11.erg.cuhk.hk
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0b6a (Win16; I)
  13.  
  14. Hi all,
  15.  
  16. I try to use dynamic array to store series of floating point.  
  17. But error message returns.  However, there won't be any problem 
  18. when I change the all the declaration from floating point 
  19. to integer.
  20.  
  21. The message I get is:
  22. "scanf: floating point formats not linked"
  23. "abnormal program termination"
  24.  
  25. The program is as follows:
  26.  
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29.  
  30. main()
  31. {
  32.     int     n, k;
  33.     float   *base, *ptr;
  34.  
  35.     scanf("%d", &n);
  36.     base=calloc(n, sizeof(float));
  37.     for(ptr=base, k=0;k<n;k++)
  38.     scanf("%f", ptr++);
  39.     for(ptr=base+n, k=0;k<n;k++)
  40.     printf("%f\n", *(--ptr));
  41.     free(base);
  42. }
  43.  
  44.  
  45. Can anybody here can drew some light on it?
  46.  
  47. Lawrence
  48.